<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>大小写转换</title>
</head>

<body>
    <script>
        function str1(str) {
            for (let i = 0; i < str.length; i++) {
                if (str.charCodeAt(i) >= '97' && str.charCodeAt(i) <= '122') {
                    str = str.replace(str[i],str[i].toUpperCase())
                    // console.log(str);
                }
                else{
                    str = str.replace(str[i],str[i].toLowerCase())
                    // console.log(str);
                }
            }return str
        }
        let str2 = 'aBcDe'
        console.log(str2);
        console.log('=================');
        let newstr2 = str1(str2)
        console.log(newstr2);
    </script>
</body>

</html>